home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games: Greatest Hits 1996 / Amiga Games: Greatest Hits 1996.iso / spiele / publicdomain / amigamud-tt / magic / grimoire.m < prev    next >
Text File  |  1996-07-05  |  7KB  |  252 lines

  1. /*
  2.  * magic/grimoire.m - Grimoire items
  3.  */
  4.  
  5.  
  6. define tp_magic proc SearchGrimoire(thing book; string spellName)thing:
  7.   thing c, theSpell;
  8.   status st;
  9.  
  10.   st:=fail;
  11.   c:=book;
  12.   theSpell:=nil;
  13.  
  14.   while st=fail and c~=nil do
  15.     if c@p_pLearnt ~= nil then
  16.       st := FindName(c@p_pLearnt,p_sName,spellName);
  17.       if st ~= fail then
  18.     theSpell:=FindResult();
  19.       fi;
  20.     fi;
  21.     c:=Parent(c);
  22.   od;
  23.  
  24.   theSpell
  25. corp;
  26.  
  27.  
  28. define tp_magic proc ReadGrimoire()string:
  29.   thing book,spell;
  30.   status st;
  31.   int count, i, sections, nospells;
  32.  
  33.   if Me()@p_pLearnt=nil then
  34.     "Alas, the arcane language makes no sense to you!"
  35.   else
  36.     book:=It();
  37.     nospells:=0;
  38.     sections:=0;
  39.     if book@p_oIsGrimoire then
  40.       while book~=nil do
  41.     count:=Count(book@p_pLearnt);
  42.     if count>0 then
  43.       nospells:=nospells+count;
  44.       sections:=sections+1;
  45.       Print("Section " + IntToString(sections) + " : " + book@p_oGrimReadPre + "\n");
  46.       for i from 0 upto count-1 do
  47.         spell:=book@p_pLearnt[i];
  48.         if spell@p_sPersist then
  49.           Print(" *");
  50.         else
  51.           Print("  ");
  52.         fi;
  53.         Print(StringReplace("    ",1,IntToString(spell@p_sLevel)));
  54.         Print(StringReplace("    ",1,IntToString(spell@p_sCost)));
  55.         Print(FormatName(spell@p_sName) + "\n");
  56.       od;
  57.       Print(book@p_oGrimReadSuf + "\n");
  58.     fi;
  59.     book:=Parent(book);
  60.       od;
  61.       "Contains " + IntToString(nospells) + " spells in " + IntToString(sections) + " sections."
  62.     else
  63.       "This is not a grimoire"
  64.     fi
  65.   fi
  66. corp;
  67.  
  68.  
  69. define tp_magic proc MakeGrimoire(thing template)thing:
  70.   thing spare;
  71.  
  72.   spare:=CreateThing(template);
  73.   spare@p_pLearnt:=CreateThingList();
  74.   spare@p_oGrimReadPre:=" ";
  75.   spare@p_oGrimReadSuf:=" ";
  76.   spare
  77. corp;
  78.  
  79.  
  80. /* Grimoire template */
  81. define tp_magic o_grimoire CreateThing(nil).
  82. o_grimoire@p_oReadAction:=ReadGrimoire.
  83. o_grimoire@p_pLearnt:=CreateThingList().
  84. o_grimoire@p_oName:="grimoire,book,tome;magic".
  85. o_grimoire@p_oIsGrimoire:=true.
  86. o_grimoire@p_oGrimReadPre:="The original tome.".
  87.  
  88. /* Wizards Grimoire */
  89. define tp_magic o_grimoire0 CreateThing(o_grimoire).
  90. o_grimoire0@p_pLearnt:=CreateThingList().
  91. o_grimoire0@p_oName:="grimoire,book,tome;powerful,magic".
  92. o_grimoire0@p_oGrimReadPre:="Divine magicks.".
  93. AddTail(o_grimoire0@p_pLearnt,CreateThing(sm_DFind)).
  94. AddTail(o_grimoire0@p_pLearnt,CreateThing(sm_DPoof)).
  95. AddTail(o_grimoire0@p_pLearnt,CreateThing(sm_DLook)).
  96. AddTail(o_grimoire0@p_pLearnt,CreateThing(sm_DHeal)).
  97. AddTail(o_grimoire0@p_pLearnt,CreateThing(sm_ObjectClone)).
  98. AddTail(o_grimoire0@p_pLearnt,CreateThing(sm_DSend)).
  99. AddTail(o_grimoire0@p_pLearnt,CreateThing(sm_DForce)).
  100. AddTail(o_grimoire0@p_pLearnt,CreateThing(sm_DTeleport)).
  101. AddTail(o_grimoire0@p_pLearnt,CreateThing(sm_DWhere)).
  102.  
  103. /* Mortals grimoire */
  104. define tp_magic o_grimoire1 CreateThing(o_grimoire).
  105. o_grimoire1@p_pLearnt:=CreateThingList().
  106. o_grimoire1@p_oName:="grimoire,book,tome;blue,magic".
  107. o_grimoire1@p_oGrimReadPre:="Mortal magicks.".
  108. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_MinorHeal)).
  109. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_MajorHeal)).
  110. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_TrueHeal)).
  111. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_SetTimer)).
  112. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Might)).
  113. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Might2)).
  114. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Might3)).
  115. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Speed)).
  116. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Speed2)).
  117. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Speed3)).
  118. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Endurance)).
  119. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Endurance2)).
  120. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Endurance3)).
  121. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Light)).
  122. AddTail(o_grimoire1@p_pLearnt,CreateThing(sm_Light2)).
  123.  
  124. /* Mana grimoire */
  125. define tp_magic o_grimoire2 CreateThing(o_grimoire).
  126. o_grimoire2@p_pLearnt:=CreateThingList().
  127. o_grimoire2@p_oName:="grimoire,book,tome;red,magic".
  128. o_grimoire2@p_oGrimReadPre:="Mana currents.".
  129. AddTail(o_grimoire2@p_pLearnt,CreateThing(sm_Scroll)).
  130. AddTail(o_grimoire2@p_pLearnt,CreateThing(sm_Potion)).
  131. AddTail(o_grimoire2@p_pLearnt,CreateThing(sm_MemLock)).
  132. AddTail(o_grimoire2@p_pLearnt,CreateThing(sm_GrantMagery)).
  133. AddTail(o_grimoire2@p_pLearnt,CreateThing(sm_RestoreMana)).
  134. AddTail(o_grimoire2@p_pLearnt,CreateThing(sm_RestoreMana2)).
  135.  
  136.  
  137. /* Verbs */
  138.  
  139. define tp_magic proc m_learn(string spell, sour)bool:
  140.   string sourName;
  141.   status st;
  142.   thing me, here, item, theSpell;
  143.   action act;
  144.   character ch;
  145.  
  146.   me := Me();
  147.   if me@p_pLearnt=nil then
  148.     false
  149.   else
  150.     here := Here();
  151.     sourName  := FormatName(sour);
  152.  
  153.     /* locate source */
  154.     st := FindName(me@p_pCarrying, p_oName, sour);
  155.     if st=succeed then
  156.       item := FindResult();
  157.       if item@p_pLearnt ~= nil then
  158.     theSpell:=SearchGrimoire(item,spell);
  159.     if theSpell ~= nil then
  160.       act:=theSpell@p_sLearnCheck;
  161.       if act~=nil then
  162.         st := call(act, status)(me,theSpell);
  163.       fi;
  164.       if st=succeed then
  165.         AddTail(me@p_pLearnt,CreateThing(theSpell) );
  166.         Print("You have learnt the " + FormatName(theSpell@p_sName) + " spell.\n");
  167.         true
  168.       else
  169.         false
  170.       fi
  171.     elif st = continue then
  172.       Print(FormatName(spell) + " is ambiguous.\n");
  173.       false
  174.     else
  175.       Print(AAn(sourName + " does not contain",FormatName(spell)) + " spell.\n");
  176.       false
  177.     fi
  178.       else
  179.     Print(AAn("You can not learn spells from",sourName) +"!\n");
  180.     false
  181.       fi
  182.     elif st=continue then
  183.       Print(sourName + " is ambiguous.\n");
  184.       false
  185.     else
  186.       if MatchName(here@p_rScenery, sour) ~= -1 then
  187.     Print("You can't learn spells from the scenery!\n");
  188.       else
  189.     Print("There is no " + sourName + " here!\n");
  190.      fi;
  191.      false
  192.     fi
  193.   fi
  194. corp;
  195.  
  196. Verb2(G, "mlearn", FindAnyWord(G, "from"), m_learn).
  197.  
  198. define tp_magic proc m_scribe(string scrollName, dest)bool:
  199.   thing me,spell,book;
  200.   status st;
  201.  
  202.   me:=Me();
  203.   if me@p_pLearnt=nil then
  204.     Print("You are not a mage!\n");
  205.     false
  206.   else
  207.     /* look for scroll */
  208.     st:=FindName(me@p_pCarrying,p_oName,scrollName);
  209.     if st = succeed then
  210.       spell:=FindResult();
  211.       if dest="?" then
  212.     Print("Scribe <spell> to <grimoire>.\n");
  213.     false
  214.       else
  215.     /* look for grimoire */
  216.     st:=FindName(me@p_pCarrying,p_oName,dest);
  217.     if st=succeed then
  218.       book:=FindResult();
  219.       if book@p_oIsGrimoire=true then
  220.         AddTail( book@p_pLearnt, CreateThing(Parent(spell)) );
  221.         ClearThing(spell);
  222.         DelElement(me@p_pCarrying,spell);
  223.         Print("You carefully scribe the scroll into your grimoire.\n");
  224.         true
  225.       else
  226.         Print(dest + " is not a grimoire.\n");
  227.         false
  228.       fi
  229.     elif st=continue then
  230.       Print(dest + " is ambiguous.\n");
  231.       false
  232.     else
  233.       Print(AAn("You do not have",dest) +"\n");
  234.       false
  235.     fi
  236.       fi
  237.     elif st=continue then
  238.       Print(scrollName + " is ambiguous.\n");
  239.       false
  240.     else
  241.       Print(AAn("You do not have",scrollName) +"\n");
  242.       false
  243.     fi
  244.   fi
  245. corp;
  246. Verb2(G, "scribe", FindAnyWord(G, "in"), m_scribe).
  247. Verb2(G, "scribe", FindAnyWord(G, "to"), m_scribe).
  248. Verb2(G, "scribe", FindAnyWord(G, "on"), m_scribe).
  249.  
  250. /**** End of file ****/
  251.  
  252.